/**
 * 
 */
package kr.co.insoft.core.service.comparison.monthly.impl;

import java.util.List;

import kr.co.insoft.auth.model.security.User;
import kr.co.insoft.core.model.comparison.monthly.MonthlyEntityModel;
import kr.co.insoft.core.model.comparison.monthly.MonthlyResultEntityModel;
import kr.co.insoft.core.repository.comparison.monthly.MonthlyRepository;
import kr.co.insoft.core.service.comparison.monthly.MonthlyService;
import kr.co.insoft.framework.exceptions.ExceptionCode;
import kr.co.insoft.framework.exceptions.RepositoryException;
import kr.co.insoft.framework.exceptions.ServiceException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;

/**
 * @author IN-SOFT Inc. Park Jong Taek(jtpark@in-soft.co.kr)
 * 
 */
@Service
public class MonthlyServiceImpl implements MonthlyService {
	
	@Autowired
	MonthlyRepository monthlyRepository;
	
	/*
	 * (non-Javadoc)
	 * 
	 * kr.co.insoft.core.service.setting.template.script.ScriptService#getPagingList
	 */
	@Override
	public List<MonthlyResultEntityModel> getChartData(MonthlyEntityModel monthlyEntityModel)
			throws ServiceException {
		try {
			Authentication auths = SecurityContextHolder.getContext()
					.getAuthentication();

			monthlyEntityModel.setAuth((User) auths.getPrincipal());
			
			return monthlyRepository.getChartData(monthlyEntityModel);
		} catch (RepositoryException e) {
			throw new ServiceException(ExceptionCode.SERVICE_EXCEPTION, e);
		}
	}
}
